package com.digitalchina.lxnsy.activity.farmVideo;

import android.content.Intent;
import android.webkit.JavascriptInterface;

import com.digitalchina.lxnsy.base.BaseHtmlActivity;
import com.digitalchina.lxnsy.constant.URL;
import com.digitalchina.lxnsy.toolkit.GotoUtil;
import com.digitalchina.lxnsy.toolkit.JointImageUrl;
import com.digitalchina.lxnsy.toolkit.StringUtil;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * ================================================
 * 项目名称：android
 * 类描述：农业视频列表
 * 创建人：yzm
 * 创建时间：2020/1/8 17:26
 * 修改备注：
 * ================================================
 */
public class VideoListActivity extends BaseHtmlActivity {

    public static final int REQUEST_CODE = 100;

    @Override
    protected void loadHtml() {
        webView.addJavascriptObject(new JsApi(), null);
        loadUrl("video-video-list");
        setTitle("农业视频");
    }

    @Override
    public void rightOnClick() {

    }

    public class JsApi {
        //类型选择
        @JavascriptInterface
        public void goSelectType(Object msg) {
            go(TypeChooseActivity.class);
        }

        //农技视频详情
        @JavascriptInterface
        public void goAgriTechVideoDetail(Object msg) {
            go(VideoDetailActivity.class);
        }
        //小视频详情
        @JavascriptInterface
        public void smallVideo(Object msg) {
            go(SmallVideoActivity.class,"msg",msg.toString());
        }

        //去评论
        @JavascriptInterface
        public void goEvalOper(Object msg) {
            go(CommentActivity.class, "msg", msg.toString());
        }

        //分享
        @JavascriptInterface
        public void share(Object msg) {

        }

        //发布
        @JavascriptInterface
        public void addVideo(Object msg) {
            GotoUtil.gotoForResultActivity(activity, AgrVideoEditActivity.class,REQUEST_CODE,"msg", msg.toString() );
        }

        //去个人主页
        @JavascriptInterface
        public void toPersonHomePage(Object msg) {
            go(PersonActivity.class);
        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
//            callJsMethod("refresh");
        }
    }
}
